package com.cn.lyl.servlet.company;

import com.alibaba.fastjson.JSONObject;
import com.cn.lyl.model.CompanyModel;
import com.cn.lyl.service.CompanyService;
import com.cn.lyl.service.impl.CompanyServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/back/company/edit")
public class EditCompanyServlet extends HttpServlet {
    @Override

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        String name = req.getParameter("name");
        String phone = req.getParameter("phone");
        String mobile =req.getParameter("mobile");
        String mail =req.getParameter("mail");
        String fax =req.getParameter("fax");
        String post =req.getParameter("post");
        String location =req.getParameter("location");
        String intro =req.getParameter("intro");

        CompanyService companyService=new CompanyServiceImpl();
        CompanyModel companyModel =companyService.find() ;
        companyModel.setName(name);
        companyModel.setIntro(intro);
        companyModel.setLocation(location);
        companyModel.setPost(post);
        companyModel.setFax(fax);
        companyModel.setMail(mail);
        companyModel.setPhone(phone);
        companyModel.setMobile(mobile);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result",companyService.edit(companyModel));
        resp.getWriter().print(jsonObject);
    }
}

